#ifndef IO_HANDLER_H
#define IO_HANDLER_H
#include "io_session.h"
namespace vpm
{
    namespace mina
    {
        class IoHandler
        {
		private:
			bool m_bConnected;

        public:

                template <class S,class C> 
                    IoSession * create_session(C  cfg)
                    {
                        return  new S(cfg); 
                    }

                virtual ~IoHandler()
                {
                }

				bool is_connected()
				{
					return m_bConnected;
				}

                virtual void sesion_created(IoSession & session)
                {

                }
				//should implement a template method to set the connection state
                virtual void session_opened(IoSession & session)
                {

                }

                virtual void session_closed(IoSession & session)
                {

                }

				/*
					return value : 0 , not complete , -1 , package error, > 0 package length
				*/
				virtual int message_demarcation(IoSession & session , char * pData, size_t len)
				{
					return len; 
				}

                virtual void message_received(IoSession & session,MessageContext & msg)
                {

                }

                //when on asynchronous mode, it will be notified when message has been sent
                virtual void message_sent(IoSession & session, MessageContext & msg)
                {

                }
        };

    }
}

#endif // 

